<include file="../header" />
<body class="J_scroll_fixed">
    <script>

        $(function() {
             

            $('input[name=number]').keyup(function() {
                var number = $(this).val();
                
                //正则判断是否为数字
                if(!/^[0-9]+$/.test(number)) {
                    layer.msg('次数应为数字!');
                    return false;
                }
            });
            $('input[name=price]').keyup(function() {
                var price = $(this).val();
                
                //正则判断是否为数字
                if(!/^[0-9]+$/.test(price)) {
                    layer.msg('总额应为数字!');
                    return false;
                }
            });
            $('button.buy').click(function () {
                var number = $("input[name=number]").val();
                var price = $("input[name=price]").val();
                //正则判断是否为数字
                if(!/^[0-9]+$/.test(number)||number===''||number===null) {
                    layer.msg('次数应为数字且不能为空!');
                    return false;
                }
                if(!/^[0-9]+$/.test(price)||price===''||price===null) {
                    layer.msg('总额应为数字且不能为空!');
                    return false;
                }else{
                    $("#buyForm").submit();
                }
            });
            
        
        });

    </script>
    <div class="wrap jj">
        <div class="common-form">
            <form id="buyForm" method="post" class="form-horizontal J_ajaxForm" action="{:U('Company/buyPost')}">
                <input type='hidden' name='id' value='{$companyId}' />
                <fieldset>
                   
                    <div class="control-group">
                        <label class="control-label">次数：</label>
                        <div class="controls">
                            <input type="text" class="input" name="number" value="" placeholder='请输入整数'>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">总额：</label>
                        <div class="controls">
                            <input type="text" class="input" name="price" value="" placeholder="请输入整数">
                        </div>
                    </div>
                </fieldset>
                <div class="form-actions">
                    <button  class="buy btn btn-primary">购买</button>
                </div>
            </form>
        </div>
    </div>
	<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>